package indi.cyh.fastservice.base;

/**
 * @Description TODO
 * @Author CYH
 * @Date 2021/9/1 10:02
 **/
public class Enums {

    /**
     * 排序类型
     */
    public enum OrderType {

        ASC(0),
        DESC(1);
        private int value;

        OrderType(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public static OrderType valueOf(int value) throws Exception {
            switch (value) {
                case 0:
                    return ASC;
                case 1:
                    return DESC;
                default:
                    throw new Exception("未知的排序类型" + value);
            }
        }
    }

    /**
     * 比较类型
     */
    public enum CompareType {

        EQUALS(0),
        LIKE(1);
        private int value;

        CompareType(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public static CompareType valueOf(int value) throws Exception {
            switch (value) {
                case 0:
                    return EQUALS;
                case 1:
                    return LIKE;
                default:
                    throw new Exception("未知的比较类型" + value);
            }
        }
    }

    /**
     * 值转换
     */
    public enum ConversionType {
        //不转换
        SOURCE(0),
        //转换为时间戳
        TIMESTAMP(1);
        private int value;

        ConversionType(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public static ConversionType valueOf(int value) throws Exception {
            switch (value) {
                case 0:
                    return SOURCE;
                case 1:
                    return TIMESTAMP;
                default:
                    throw new Exception("未知的转换类型" + value);
            }
        }
    }

}
